package com.example.order.controller;

import com.example.order.Service.OrderService;
import com.example.order.dao.OdersDAO;
import com.example.order.entity.OdersEntity;
import com.example.vo.OrderVIO;
import io.seata.core.exception.TransactionException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("orders")
@Api("下订单相关")
@RequestMapping("orders")
public class OrderController {
    @Autowired
    OdersDAO odersDAO;

    @Autowired
    OrderService orderService;
    @ApiOperation("查询订单")
    @GetMapping("/getorder")
    public List<OdersEntity> getOrders(){

        return  odersDAO.getOders();
    }
    @ApiOperation("创建订单")
    @PostMapping("createOrder")
    public boolean createOrder(@RequestBody  OrderVIO orderVIO) throws TransactionException {

        return orderService.createOrder(orderVIO);
    }
}
